#!/bin/sh

if ! command -v nmap >/dev/null 2>&1; then
	echo >&2 "'nmap' not found"
	exit 1
fi

SUBNET="$(ifconfig | awk '/inet:?/ && $0 !~ "127.0.0.1" {gsub(/\.[0-9]+$/, ".*", $2); gsub(/.*:/, "", $2) ; print $2}')"
echo "Scanning '$SUBNET'..."
nmap -sn "$SUBNET"
